package com.qf.service.impl;

import com.qf.entity.WmsCkManage;
import com.qf.mapper.WmsApplyCkMapper;
import com.qf.service.WmsApplyCkService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@Service
public class WmsApplyCkServiceImpl implements WmsApplyCkService {

    @Autowired
    private WmsApplyCkMapper mapper;

    /**
     *查询全部，并且进行分页
     * @param map
     * @return
     */
    @Override
    public List<WmsCkManage> findAll(HashMap<String, String> map) {
        return mapper.findAll(map);
    }

    /**
     * 更新库存数量
     * @param wmsCkManage
     * @return
     */
    @Override
    public boolean applyck(WmsCkManage wmsCkManage) {
        int kcNum = wmsCkManage.getInventoryQuantity();//获取库存数量
        int ckNum = wmsCkManage.getQuantity();//获取出库数量
        int result = kcNum-ckNum;//这个数据是出库后，剩余的库存辆
        wmsCkManage.setInventoryQuantity(result);
        if(result<0){
            return false;
        }else {
            return mapper.applyck(wmsCkManage);
        }

    }

    @Override
    public List<WmsCkManage> select() {
        return mapper.select();
    }

    /**
     * 查找分类下拉框
     * @return
     */
    @Override
    public List<WmsCkManage> selectByClassify() {
        return mapper.selectByClassify();
    }

    @Override
    public List<WmsCkManage> selectByName() {
        return mapper.selectByName();
    }

    @Override
    public List<WmsCkManage> selectByBrand() {
        return  mapper.selectByBrand();
    }

    @Override
    public void ck(Integer id , int rul ) {
        mapper.ck(id, rul);

    }



}
